package com.hhsjdesign.dynamicui.asm.v1
/**
 * 扫描带指定注解带类
 *
 */
class ScanSetting {
    static final String PLUGIN_NAME = "hhsjdesign_dynamicui_asm_plugin"
    /**
     * The register code is generated into this class
     * com.hhsjdesign.dynamicui.core.DynamicUIConfigImpl 目标类
     * com.hhsjdesign.dynamicui.utils.DynamicUIConfigImplJava
     */
    static final String GENERATE_TO_CLASS_NAME = 'com/hhsjdesign/dynamicui/utils/DynamicUIConfigImplJava'
    /**
     * you know. this is the class file(or entry in jar file) name
     */
    static final String GENERATE_TO_CLASS_FILE_NAME = GENERATE_TO_CLASS_NAME + '.class'
    /**
     * The register code is generated into this method
     */
    static final String GENERATE_TO_METHOD_NAME1 = 'widgetViewTypeList'
    static final String GENERATE_TO_METHOD_NAME2 = 'businessBeanTypeList'
    static final String GENERATE_TO_METHOD_NAME3 = 'widgetDataTypeList'
    static final String GENERATE_TO_METHOD_NAME4 = 'widgetPropertyTypeList'
    static final String GENERATE_TO_METHOD_NAME5 = 'viewHolderTypeList'
    static final String GENERATE_TO_METHOD_NAME6 = 'dataCallerTypeList'
    static final String GENERATE_TO_METHOD_NAME7 = 'widgetItemViewTypeList'

    /**
     * The package name of the class generated by the annotationProcessor
     * com.hhsjdesign.dynamicui.generate.DynamicUIMap__[bus_advert]
     */
    static final String DYNAMICUI_CLASS_PACKAGE_NAME = 'com/hhsjdesign/dynamicui/generate'
    /**
     * The package name of the interfaces
     *
     * //
     * com.hhsjdesign.dynamicui.core
     */
    private static final INTERFACE_PACKAGE_NAME = 'com/hhsjdesign/dynamicui/core/'

    /**
     * register method name in class: {@link #GENERATE_TO_CLASS_NAME}
     */
    static final String REGISTER_METHOD_NAME1 = 'beans'
    static final String REGISTER_METHOD_NAME2 = 'viewHolders'
    static final String REGISTER_METHOD_NAME3 = 'callers'

    /**
     * scan for classes which implements this interface
     */
    String interfaceName = ''

    /**
     * jar file which contains class: {@link #GENERATE_TO_CLASS_NAME}
     */
    File fileContainsInitClass
    /**
     * scan result for {@link #interfaceName}
     * class names in this list
     */
    HashSet<String> classList = new HashSet<>()

    static Map<String, Class> taskClazz = new HashMap<String, Class>();
    /**
     * constructor for arouter-auto-register settings
     * @param interfaceName interface to scan
     */
    ScanSetting(String interfaceName) {
        this.interfaceName = INTERFACE_PACKAGE_NAME + interfaceName
    }

    /**
     * key 注解类型
     * value 注解类型的类名
     */
    Map<String, HashSet<String>> targetClassName = new HashMap<>()

    /**
     * 防止重复
     */
    static final HashSet<AnnoValue> annoValueSet = new HashSet<>()

    static final String ADynamicUI = "com.hhsjdesign.dynamicui.annoprocess.ADynamicUI"
    static final String ABusinessBean = "com.hhsjdesign.dynamicui.annoprocess.ABusinessBean"
    static final String ABusinessCaller = "com.hhsjdesign.dynamicui.annoprocess.ABusinessCaller"
    static final String ABusinessViewHolder = "com.hhsjdesign.dynamicui.annoprocess.ABusinessViewHolder"
    static final String AFromJSON = "com.hhsjdesign.dynamicui.annoprocess.AFromJSON"
    static final String AWidgetData = "com.hhsjdesign.dynamicui.annoprocess.AWidgetData"
    static final String AWidgetItemData = "com.hhsjdesign.dynamicui.annoprocess.AWidgetItemData"
    static final String AWidgetProperty = "com.hhsjdesign.dynamicui.annoprocess.AWidgetProperty"
    static final String AWidgetType = "com.hhsjdesign.dynamicui.annoprocess.AWidgetType"

    static class AnnoValue {
        public String annoType
        public String annoValue
        public String className

        AnnoValue(String annoType, String annoValue, String className) {
            this.annoType = annoType
            this.annoValue = annoValue
            this.className = className
        }

        @Override
        boolean equals(Object obj) {
            if (obj == this) return true
            if (obj instanceof AnnoValue) {
                return obj.annoType == this.annoType
                        && obj.annoValue == this.annoValue
                        && obj.className == this.className
            }
            return super.equals(obj)
        }

        @Override
        int hashCode() {
            int result = 17;
            result = 31 * result + (annoType == null ? 0 : annoType.hashCode());
            result = 31 * result + (annoValue == null ? 0 : annoValue.hashCode());
            result = 31 * result + (className == null ? 0 : className.hashCode());
            return result;
        }

        @Override
        String toString() {
            return ">>type:${annoType} value:${annoValue} className:${className}"
        }
    }
}